package util;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

public class StadiumNameValidator implements Validator {

    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        String n = String.valueOf(value);
        if ((n == null) || (n.length() == 0)) {
            return;
        }
        if (n.length() > 20) {
            throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Název stadiunu nesmí být delší než 20 znaků", null));
        }
    }

}
